﻿using ApiGateway;
using System.Collections.Generic;
using HttpApiGateway;
using HttpApiGateway.Model;
using RpcHelper.Validate;
using RpcModel;
using Wedonek.RpcStore.Gateway.Interface;
using Wedonek.RpcStore.Gateway.Model;
using RpcClient;

namespace Wedonek.RpcStore.Gateway.Controller
{
    /// <summary>
    /// 节点访问统计
    /// </summary>
    internal class VisitCensusController : ApiController
    {
        private readonly IServerVisitCensusService _Service;
        public VisitCensusController(IServerVisitCensusService server)
        {
            this._Service = server;
        }
        /// <summary>
        /// 查询服务节点统计信息
        /// </summary>
        /// <param name="paging"></param>
        /// <returns></returns>
        public PagingResult<VisitCensus> Query(BasicPage paging)
        {
            VisitCensus[] list = this._Service.Query(paging, out long count);
            return new PagingResult<VisitCensus>(list, count);
        }
        /// <summary>
        /// 重置服务节点统计
        /// </summary>
        /// <param name="serverId"></param>
        public void Reset([NumValidate("rpc.server.id.error", 1)] long serverId)
        {
            this._Service.Reset(serverId);
        }
        /// <summary>
        /// 设置节点访问统计的备注说明
        /// </summary>
        /// <param name="param"></param>
        public void SetShow(GuidParam<string> param)
        {
            this._Service.SetShow(param.Id, param.Param);
        }
    }
}
